<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('添加新闻')" />
    <th:block th:include="include :: datetimepicker-css"/>
    <th:block th:include="include :: bootstrap-fileinput-css"/>
    <th:block th:include="include :: summernote-css"/>
    <th:block th:include="include :: jquery-smartwizard-css"/>
    <th:block th:include="include :: select2-css"/>
    <th:block th:include="include :: bootstrap-select-css"/>
    <th:block th:include="include :: summernote-css"/>

</head>
<script src="../static/js/xm-select.js" th:src="@{/js/xm-select.js}"></script>

<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-otherNews-add">
        <input name="classify" id="classify" th:value=${classify} type="hidden">
        <div class="tab-content">

            <div class="form-group">
                <div class="col-sm-6">
                    <label class="col-sm-2 control-label">文章标题</label>
                    <div class="col-sm-10">
                        <input name="name" class="form-control" type="text">
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-2 control-label">关键词</label>
                    <div class="col-sm-10">
                        <input name="keyword" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-6">
                    <label class="col-sm-2 control-label">作者来源</label>
                    <div class="col-sm-10">
                        <input name="authorSource" class="form-control" type="text">
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-2 control-label">标签</label>
                    <div class="col-sm-10">
                        <label class="radio-box"> <input type="radio"  name="label"  value="0"  checked/> 不选择 </label>
                        <label class="radio-box"> <input type="radio"  name="label"  value="1" /> 头条 </label>
                        <label class="radio-box"> <input type="radio"  name="label"  value="2" /> 顶置 </label>
                        <label class="radio-box"> <input type="radio"  name="label"  value="3" /> 推荐 </label>
                        <label class="radio-box"> <input type="radio"  name="label"  value="4" /> 特推 </label>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-1 control-label">描述</label>
                <div class="col-sm-11">
                    <textarea name="description" class="form-control" type="text"></textarea>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-12">
                    <label class="col-sm-1 control-label">主图</label>
                    <div class="col-sm-11">
                        <input type="hidden" name="icon">
                        <div class="file-loading">
                            <input class="form-control file-upload" id="icon" name="file" type="file">
                        </div>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-12">
                    <label class="col-sm-1 control-label">内容</label>
                    <div class="col-sm-11">
                        <input type="hidden" class="form-control" required>
                        <script id="content" name="content" type="text/plain"></script>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-1 control-label">温馨提示</label>
                <div class="col-sm-11">
                    <textarea name="warmPrompt" class="form-control" type="text"></textarea>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-1 control-label">参考资料</label>
                <div class="col-sm-11">
                    <textarea name="referenceMaterial" class="form-control" type="text"></textarea>
                </div>
            </div>
        </div>
    </form>
</div>

<th:block th:include="include :: footer"/>
<th:block th:include="include :: datetimepicker-js"/>
<th:block th:include="include :: bootstrap-fileinput-js"/>
<th:block th:include="include :: summernote-js"/>
<th:block th:include="include :: jquery-smartwizard-js"/>
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: bootstrap-select-js"/>
<th:block th:include="include :: summernote-js"/>
<script src="/ueditor/ueditor.config.js" type="text/javascript" charSet="utf-8"></script>
<script src="/ueditor/ueditor.all.js" type="text/javascript" charSet="utf-8"></script>
<script src="/ueditor/lang/zh-cn/zh-cn.js" type="text/javascript" charSet="utf-8"></script>
<script th:inline="javascript">


    var prefix = ctx + "ydz/otherNews"
    $("#form-otherNews-add").validate({
        focusCleanup: true
    });
    function remove(e) {
        $(e).parent().remove();
    }
    $(document).ready(function () {

        $(".select2-allow-clear").select2({
            allowClear: true,
            width: null
        });
        parent.$('body').find('.layui-layer-max:not(.layui-layer-maxmin)').click()


    })


    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/add", $('#form-otherNews-add').serialize());
        }
    }

    $(".file-upload").fileinput({
        uploadUrl: ctx + 'common/upload',
        maxFileCount: 1,
        autoReplace: true
    }).on('fileuploaded', function (event, data, previewId, index) {
        $("input[name='" + event.currentTarget.id + "']").val(data.response.fileName)
    }).on('fileremoved', function (event, id, index) {
        $("input[name='" + event.currentTarget.id + "']").val('')
    })

    //富文本
    UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl;
    UE.Editor.prototype.getActionUrl = function (action) {
        if (action == 'uploadimage' || action == 'uploadscrawl') {
            return '/common/upload';
        } else {
            return this._bkGetActionUrl.call(this, action);
        }
    }

    var content = UE.getEditor('content', {
        autoHeightEnabled: false,//是否自动长高
        autoFloatEnabled: true,//是否保持toolbar的位置不动
        scaleEnabled: true,//是否可以拉伸长高
        initialFrameWidth: 'auto',//初始化编辑器宽度
        initialFrameHeight: 300,//初始化编辑器高度
    });
    content.ready(function () {
    })



</script>
</body>
</html>